#pragma once
#include "log/channel.hpp"
#include "log/message.hpp"
#include "event/mutex.hpp"
using JHCPP::event::CMutex;
#include <string>

namespace JHCPP
{
	namespace log
	{
		class CWindowsConsoleChannel : public CChannel
		{
		public:
			CWindowsConsoleChannel();
			void log(const CMessage& msg);

		protected:
			~CWindowsConsoleChannel();

		private:
			HANDLE m_hConsole;
			bool   m_isFile;
		};


		class CWindowsColorConsoleChannel : public CChannel
		{
		public:
			CWindowsColorConsoleChannel();
			void log(const CMessage& msg);

			void setProperty(const std::string& name, const std::string& value);
			std::string getProperty(const std::string& name) const;

		protected:
			enum Color
			{
				CC_BLACK        = 0x0000,
				CC_RED          = 0x0004,
				CC_GREEN        = 0x0002,
				CC_BROWN        = 0x0006,
				CC_BLUE         = 0x0001,
				CC_MAGENTA      = 0x0005,
				CC_CYAN         = 0x0003,
				CC_GRAY         = 0x0007,
				CC_DARKGRAY     = 0x0008,
				CC_LIGHTRED     = 0x000C,
				CC_LIGHTGREEN   = 0x000A,
				CC_YELLOW       = 0x000E,
				CC_LIGHTBLUE    = 0x0009,
				CC_LIGHTMAGENTA = 0x000D,
				CC_LIGHTCYAN    = 0x000B,
				CC_WHITE        = 0x000F
			};

			~CWindowsColorConsoleChannel();
			WORD parseColor(const std::string& color) const;
			std::string formatColor(WORD color) const;
			void initColors();

		private:
			bool	m_enableColors;
			HANDLE	m_hConsole;
			bool	m_isFile;
			WORD	m_colors[9];
		};
	}//end of namespace log
}//end of namespace JHCPP
